// eslint-disable-next-line
import { BasicLayout, PageView, RouteView, UserLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

/**
 * 角色权限 tree 用的也是此 Map 有些 hidden 是 菜单里不显示, 但是权限那里要用到
 */
export const asyncRouterMap = [
  {
    path: '/',
    component: BasicLayout,
    meta: { title: '根目录' },
    children: [
      {
        path: '/',
        name: 'index',
        component: () => import('@/views/index/dashboard'),
        meta: { title: '首页', icon: 'dashboard' }
      },
      {
        path: 'commodity',
        name: 'commodity',
        component: PageView,
        meta: { title: '商品', icon: bxAnaalyse },
        children: [
          {
            path: 'commodity',
            name: 'commodity_list',
            component: RouteView,
            meta: { title: '商品库', icon: bxAnaalyse, permission: ['commodity_list'] },
            redirect: 'commodity/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/commodity/List'),
                hidden: true,
                meta: { title: '列表' }
              },
              {
                path: 'create',
                name: 'commodity_create',
                component: () => import('@/views/commodity/Form'),
                hidden: true,
                meta: { title: '添加商品' }
              },
              {
                path: 'edit/:id',
                name: 'commodity_edit',
                component: () => import('@/views/commodity/Form'),
                hidden: true,
                meta: { title: '编辑商品' }
              }
            ]
          },
          {
            path: 'category',
            name: 'commodity_category_list',
            meta: { title: '商品类别', icon: bxAnaalyse, permission: ['commodity_category_list'] },
            component: () => import('@/views/commodity/category/List')
          },
          {
            path: 'live-today',
            name: 'commodity_activity_live_today_list',
            component: RouteView,
            meta: { title: '今日直播', icon: bxAnaalyse, permission: ['commodity_activity_live_today_list'] },
            redirect: 'live-today/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/commodity/live-today/List'),
                meta: { title: '今日直播列表' }
              },
              {
                path: 'info/:id',
                name: 'commodity_activity_live_today_info',
                component: () => import('@/views/commodity/activity/Info'),
                meta: { title: '今日直播详情' }
              },
              {
                // TODO 暂时先只统一 今日直播/好评返团 创建(复制)部分,其余几处看情况再统一
                path: 'create',
                name: 'commodity_activity_live_today_create',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '创建商品活动', query: { formType: 1 } }
              },
              {
                path: 'edit/:id',
                name: 'commodity_activity_live_today_edit',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '编辑商品活动' }
              },
              {
                path: 'copy/:id',
                name: 'commodity_activity_live_today_copy',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '创建商品活动', query: { formType: 1 } }
              },
              {
                path: 'commodity_activity_live_today_upper_and_lower_shelves',
                name: 'commodity_activity_live_today_upper_and_lower_shelves',
                meta: { title: '商品上下架' },
                hidden: true
              },
              {
                path: 'forward_material/:id',
                name: 'commodity_activity_live_today_forward_material',
                component: () => import('@/views/commodity/live-today/ForwardMaterial'),
                meta: { title: '转发素材' },
                hidden: true
              },
              {
                path: 'moments_material/:id',
                name: 'commodity_activity_live_today_moments_material',
                component: () => import('@/views/commodity/live-today/MomentsMaterial'),
                meta: { title: '朋友圈素材' },
                hidden: true
              }
            ]
          },
          {
            path: 'praise-return',
            name: 'commodity_activity_praise_return_list',
            component: RouteView,
            meta: { title: '好评返团', icon: bxAnaalyse, permission: ['commodity_activity_praise_return_list'] },
            redirect: 'praise-return/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/commodity/praise-return/List'),
                meta: { title: '好评返团列表' }
              },
              {
                path: 'info/:id',
                name: 'commodity_activity_praise_return_info',
                component: () => import('@/views/commodity/activity/Info'),
                meta: { title: '好评饭团详情' }
              },
              {
                path: 'create',
                name: 'commodity_activity_praise_return_create',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '创建商品活动', query: { formType: 2 } }
              },
              {
                path: 'edit/:id',
                name: 'commodity_activity_praise_return_edit',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '编辑商品活动' }
              },
              {
                path: 'copy/:id',
                name: 'commodity_activity_praise_return_copy',
                component: () => import('@/views/commodity/activity/Form'),
                meta: { title: '创建商品活动', query: { formType: 2 } }
              },
              {
                path: 'commodity_activity_praise_return_upper_and_lower_shelves',
                name: 'commodity_activity_praise_return_upper_and_lower_shelves',
                meta: { title: '商品上下架' },
                hidden: true
              },
              {
                path: 'forward_material/:id',
                name: 'commodity_activity_praise_return_forward_material',
                component: () => import('@/views/commodity/praise-return/ForwardMaterial'),
                meta: { title: '转发素材' },
                hidden: true
              },
              {
                path: 'moments_material/:id',
                name: 'commodity_activity_praise_return_moments_material',
                component: () => import('@/views/commodity/praise-return/MomentsMaterial'),
                meta: { title: '朋友圈素材' },
                hidden: true
              }
            ]
          },
          {
            path: 'label',
            name: 'commodity_label_list',
            component: RouteView,
            meta: { title: '商品标签', icon: bxAnaalyse, permission: ['commodity_label_list'] },
            redirect: 'label/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/commodity/label/List'),
                meta: { title: '商品标签列表' }
              },
              {
                path: 'create',
                name: 'commodity_label_create',
                meta: { title: '创建商品标签' }
              },
              {
                path: 'edit',
                name: 'commodity_label_edit',
                meta: { title: '编辑商品标签' }
              },
              {
                path: 'delete',
                name: 'commodity_label_delete',
                meta: { title: '删除商品标签' }
              }
            ]
          }
        ]
      },
      {
        path: 'order',
        name: 'order',
        component: PageView,
        meta: { title: '订单', icon: bxAnaalyse },
        children: [
          {
            path: 'order',
            name: 'order_list',
            component: RouteView,
            meta: { title: '订单列表', icon: bxAnaalyse, permission: ['order_list'] },
            redirect: 'order/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/order/List'),
                hidden: true,
                meta: { title: '订单列表' }
              },
              {
                path: 'info/:id',
                name: 'order_info',
                component: () => import('@/views/order/Info'),
                hidden: true,
                meta: { title: '订单详情' }
              }
            ]
          },
          {
            path: 'after-sale',
            name: 'after_sale_order_list',
            component: RouteView,
            meta: { title: '售后订单列表', icon: bxAnaalyse, permission: ['after_sale_order_list'] },
            redirect: 'after-sale/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/order/after_sale/List'),
                hidden: true,
                meta: { title: '订单列表' }
              },
              {
                path: 'info/:id',
                name: 'after_sale_order_info',
                component: () => import('@/views/order/after_sale/Info'),
                hidden: true,
                meta: { title: '售后订单详情' }
              }
            ]
          }]
      },
      {
        path: 'proxy',
        name: 'proxy',
        component: PageView,
        meta: { title: '代理', icon: bxAnaalyse },
        children: [
          {
            path: 'partner',
            name: 'partner_list',
            component: RouteView,
            meta: { title: '合伙人', icon: bxAnaalyse, permission: ['partner_list'] },
            redirect: 'partner/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/proxy/partner/List'),
                meta: { title: '合伙人列表' }
              }
            ]
          },
          {
            path: 'website-letter',
            name: 'website_letter_list',
            component: RouteView,
            meta: { title: '站内信', icon: bxAnaalyse, permission: ['website_letter_list'] },
            redirect: 'website-letter/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/proxy/website-letter/List'),
                meta: { title: '站内信列表' }
              },
              {
                path: 'create',
                name: 'website_letter_create',
                component: () => import('@/views/proxy/website-letter/Form'),
                meta: { title: '创建站内信' },
                hidden: true
              },
              {
                path: 'edit/:id',
                name: 'website_letter_edit',
                component: () => import('@/views/proxy/website-letter/Form'),
                meta: { title: '编辑站内信' },
                hidden: true
              },
              {
                path: 'delete',
                name: 'website_letter_delete',
                meta: { title: '删除站内信' },
                hidden: true
              }
            ]
          },
          {
            path: 'agent',
            name: 'agent_list',
            component: RouteView,
            meta: { title: '代理商', icon: bxAnaalyse, permission: ['agent_list'] },
            redirect: 'agent/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/proxy/agent/List'),
                meta: { title: '列表' }
              },
              {
                path: 'info/:id',
                name: 'agent_info',
                component: () => import('@/views/proxy/agent/Info'),
                meta: { title: '详情' }
              },
              {
                path: 'create',
                name: 'agent_create',
                component: () => import('@/views/proxy/agent/Form'),
                meta: { title: '创建代理商' },
                hidden: true
              },
              {
                path: 'edit',
                name: 'agent_edit',
                component: () => import('@/views/proxy/agent/Form'),
                meta: { title: '编辑代理商' },
                hidden: true
              },
              {
                path: 'delete',
                name: 'agent_delete',
                meta: { title: '删除代理商' },
                hidden: true
              }
            ]
          },
          {
            path: 'agent-label',
            name: 'agent_label_list',
            component: RouteView,
            meta: { title: '标签管理', icon: bxAnaalyse, permission: ['agent_label_list'] },
            redirect: 'agent-label/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/proxy/agent-label/List'),
                meta: { title: '标签列表' }
              },
              {
                path: 'create',
                name: 'agent_label_create',
                meta: { title: '创建标签' },
                hidden: true
              },
              {
                path: 'edit',
                name: 'agent_label_edit',
                meta: { title: '编辑标签' },
                hidden: true
              },
              {
                path: 'delete',
                name: 'agent_label_delete',
                meta: { title: '删除标签' },
                hidden: true
              }
            ]
          },
          {
            path: 'agent-rule-setting-table',
            name: 'agent_rule_setting_table',
            component: () => import('@/views/proxy/AgentRule'),
            meta: { title: '规则设置', icon: bxAnaalyse, permission: ['agent_rule_setting_table'] }
          }
        ]
      },
      {
        path: 'supplier',
        component: PageView,
        meta: { title: '供应商', icon: bxAnaalyse },
        children: [
          {
            path: 'supplier',
            name: 'supplier_list',
            component: RouteView,
            meta: { title: '供应商列表', icon: bxAnaalyse, permission: ['supplier_list'] },
            redirect: 'supplier/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/supplier/List'),
                meta: { title: '供应商列表', icon: bxAnaalyse }
              },
              {
                path: 'create',
                name: 'supplier_create',
                component: () => import('@/views/supplier/Form'),
                hidden: true,
                meta: { title: '创建供应商' }
              },
              {
                path: 'edit/:id',
                name: 'supplier_edit',
                component: () => import('@/views/supplier/Form'),
                hidden: true,
                meta: { title: '编辑供应商' }
              },
              {
                path: 'info/:id',
                name: 'supplier_info',
                component: () => import('@/views/supplier/Info'),
                hidden: true,
                meta: { title: '供应商详情' }
              }
            ]
          }
        ]
      },
      {
        path: 'finance',
        name: 'finance',
        component: PageView,
        meta: { title: '财务', icon: bxAnaalyse },
        children: [
          {
            path: 'agent-profit',
            name: 'agent_profit_list',
            component: RouteView,
            meta: { title: '代理商利润明细', icon: bxAnaalyse, permission: ['agent_profit_list'] },
            redirect: 'agent-profit/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/finance/agentProfit/List'),
                meta: { title: '代理商列表' }
              },
              {
                path: 'detail/:id',
                name: 'agent_profit_running_bill',
                component: () => import('@/views/finance/agentProfit/Detail'),
                meta: { title: '流水明细' }
              }
            ]
          },
          {
            path: 'profit-statistics',
            name: 'commodity_profit_list',
            component: () => import('@/views/finance/profit/List'),
            meta: { title: '商品利润统计', icon: bxAnaalyse, permission: ['commodity_profit_list'] }
          },
          {
            path: 'daily-report',
            name: 'daily_report_statistics',
            component: () => import('@/views/finance/dailyReport/List'),
            meta: { title: '每日报表统计', icon: bxAnaalyse, permission: ['daily_report_statistics'] }
          },
          {
            path: 'daily-order-reward',
            name: 'daily_order_reward',
            component: () => import('@/views/finance/dailyOrderReward/List'),
            meta: { title: '每日下单奖励', icon: bxAnaalyse, permission: ['daily_order_reward'] }
          },
          {
            path: 'monthly-order-reward',
            name: 'monthly_order_reward',
            component: () => import('@/views/finance/monthlyOrderReward/List'),
            meta: { title: '每月下单奖励', icon: bxAnaalyse, permission: ['monthly_order_reward'] }
          },
          {
            path: 'activity-cultivation-award',
            name: 'cultivation_award',
            component: () => import('@/views/finance/cultivationAward/List'),
            meta: { title: '培养奖', icon: bxAnaalyse, permission: ['cultivation_award'] }
          },
          {
            path: 'after-sale-compensation',
            name: 'after_sale_compensation',
            component: () => import('@/views/finance/afterSaleCompensation/List'),
            meta: { title: '售后补偿', icon: bxAnaalyse, permission: ['after_sale_compensation'] }
          },
          {
            path: 'agent-withdrawals-record',
            name: 'agent_withdrawals_record',
            component: () => import('@/views/finance/agentWithdrawalsRecord/List'),
            meta: { title: '代理提现记录', icon: bxAnaalyse, permission: ['agent_withdrawals_record'] }
          },
          {
            path: 'financial-details',
            name: 'financial_details',
            component: () => import('@/views/finance/financeDetail/List'),
            meta: { title: '财务明细', icon: bxAnaalyse, permission: ['financial_details'] }
          }
        ]
      },
      {
        path: 'system',
        name: 'system',
        component: PageView,
        meta: { title: '系统', icon: 'warning' },
        children: [
          {
            path: 'async_export_files_download',
            name: 'async_export_files_download',
            component: () => import('@/views/system/async_export_files_download/List'),
            meta: { title: '异步导出任务', icon: 'tool', permission: ['async_export_files_download'] }
          },
          {
            path: 'courier_company',
            name: 'courier_company_list',
            component: RouteView,
            meta: { title: '快递公司', icon: 'tool', permission: ['courier_company_list'] },
            redirect: 'courier_company/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/system/courier_company/List'),
                meta: { title: '列表' }
              },
              {
                path: 'create',
                name: 'courier_company_create',
                hidden: true,
                meta: { title: '创建' }
              },
              {
                path: 'delete',
                name: 'courier_company_delete',
                hidden: true,
                meta: { title: '删除' }
              },
              {
                path: 'edit',
                name: 'courier_company_edit',
                hidden: true,
                meta: { title: '编辑' }
              }
            ]
          },
          {
            path: 'banner',
            name: 'banner_list',
            component: () => import('@/views/system/banner_management/List'),
            meta: { title: '轮播图', icon: 'tool', permission: ['banner_list'] }
          },
          {
            path: 'role_management',
            name: 'role_management_list',
            component: RouteView,
            meta: { title: '角色管理', icon: 'tool', permission: ['role_management_list'] },
            redirect: 'role_management/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/system/role_management/List'),
                meta: { title: '角色列表' }
              },
              {
                path: 'create',
                name: 'role_management_create',
                component: () => import('@/views/system/role_management/Form'),
                meta: { title: '创建角色' },
                hidden: true
              },
              {
                path: 'edit/:roleId([1-9]\\d*)',
                name: 'role_management_edit',
                component: () => import('@/views/system/role_management/Form'),
                meta: { title: '编辑角色' },
                hidden: true
              }
            ]
          },
          {
            path: 'account_management',
            name: 'account_management_list',
            component: RouteView,
            meta: { title: '账号管理', icon: 'tool', permission: ['account_management_list'] },
            redirect: 'account_management/list',
            hideChildrenInMenu: true,
            children: [
              {
                path: 'list',
                component: () => import('@/views/system/account_management/List'),
                meta: { title: '账号列表' }
              },
              {
                path: 'create',
                name: 'account_management_create',
                component: () => import('@/views/system/account_management/Form'),
                meta: { title: '创建账号' },
                hidden: true
              }
            ]
          },
          {
            path: 'operation_log',
            name: 'operation_log_list',
            component: () => import('@/views/system/OperationLog'),
            meta: { title: '操作日志', icon: 'tool', permission: ['operation_log_list'] }
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'reset-password',
        name: 'reset_password',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/ResetPassword')
      }
    ]
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
